import { BaseWindow } from "../../../../../component/window/BaseWindow";
import { ILayer } from "../../../../../mvc/interfaces/ILayer";
import { Language } from "../../../../../../extend/language/Language";
import { ItemData } from "../../../../resource/info/ItemData";
import { SkillRuneComposeConfirmSubWin } from "./SkillRuneComposeConfirmSubWin";
import { ObjCreate } from "../../../common/ObjCreate";
import { Alert } from "../../../../../../com/mui/controls/Alert";
import { Dispatcher } from "../../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../../events/DataEvent";
import { EventName } from "../../../../mvc/EventName";
import { GButton } from "../../../../../../com/mui/controls/GButton";
import { _stuffDatas } from "../../../../../../this/_stuffDatas";
import { _data } from "../../../../../../this/_data";
type int = number;
//class SkillRuneComposeConfirmWin
    
    export  class SkillRuneComposeConfirmWin extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this.setSize(400, 192);
            this.title = Language.getString(80080);
            this.titleHeight = 27;
            this._btnSwallow.addEventListener(flash.events.MouseEvent.CLICK, this.clickSwallowHandler);
            return;
        }

        public updateData(arg1: ItemData, arg2: ItemData, arg3: ItemData): void
        {
            this._stuffDatas = [];
            this._stuffDatas.push(arg1);
            this._stuffDatas.push(arg2);
            this._data = arg3;
            this._part1.updateData(arg1, arg3);
            this._part2.updateData(arg2, arg3);
            this.updateLayout();
            return;
        }

        /* internal  */updateLayout(): void
        {
            var loc1=0;
            if (this._part1.isNull) 
            {
                this._part1.visible = false;
                this._part2.visible = true;
                this._part2.x = 18;
                this._part2.y = 41;
                loc1 = this._part2.y + 52 + 15;
            }
            else if (this._part2.isNull) 
            {
                this._part1.visible = true;
                this._part2.visible = false;
                this._part1.x = 18;
                this._part1.y = 41;
                loc1 = this._part1.y + 52 + 15;
            }
            else 
            {
                this._part1.visible = true;
                this._part2.visible = true;
                this._part1.x = 18;
                this._part1.y = 41;
                this._part2.x = 18;
                this._part2.y = 93;
                loc1 = this._part2.y + 52 + 15;
            }
            this._btnSwallow.y = loc1;
            this.setSize(400, loc1 + this._btnSwallow.height + 12);
            return;
        }

        public get winPart1(): SkillRuneComposeConfirmSubWin
        {
            return this._part1;
        }

        public get winPart2(): SkillRuneComposeConfirmSubWin
        {
            return this._part2;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._part1 = new SkillRuneComposeConfirmSubWin();
            this._part1.x = 18;
            this._part1.y = 41;
            this.addChild(this._part1);
            this._part2 = new SkillRuneComposeConfirmSubWin();
            this._part2.x = 18;
            this._part2.y = 168;
            this.addChild(this._part2);
            this._btnSwallow = ObjCreate.createGButton(Language.getString(80083), 168, 307, 65, 22, this);
            return;
        }

        /* internal  */clickSwallowHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._data == null || this._stuffDatas == null || this._stuffDatas.length < 2) 
            {
                return;
            }
            this.confirmedSwallow(Alert.OK);
            return;
        }

        /* internal  */confirmedSwallow(arg1: int): void
        {
            if (arg1 == Alert.OK) 
            {
                hide();
                Dispatcher.dispatchEvent(new DataEvent(EventName.RuneConfirmSwallow, {"datas": _stuffDatas, "targetData": _data}));
            }
            return;
        }

        /* internal */ /* var */_part1: SkillRuneComposeConfirmSubWin;

        /* internal */ /* var */_part2: SkillRuneComposeConfirmSubWin;

        /* internal */ /* var */_btnSwallow: GButton;

        /* internal */ /* var */_stuffDatas: Array<any>;

        /* internal */ /* var */_data: ItemData;
    }
